package cn.git.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/** 
 * @description: 简单定时任务
 * @program: bank-credit-sy
 * @author: lixuchun
 * @create: 2024-07-10
 */
@Slf4j
@Component
//@EnableScheduling
public class TimerTask {

    /**
     * 每5秒执行一次
     */
    @Scheduled(cron = "0/5 * * * * ?")
    public void timer() {
        log.info("定时任务执行开始 : " + System.currentTimeMillis());
        if (System.currentTimeMillis() % 2 == 0) {
            throw new RuntimeException("业务异常啦!");
        }
    }
}
